<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="support.*, java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>More Degrees</title>

<script type="text/javascript">

</script>

</head>

<%
	String major = request.getParameter( "major" );
	if(major == null)
		major = request.getParameter( "majorbox" );
	
	String month = request.getParameter( "month" );
	String year = request.getParameter( "year" );
	String gpa = request.getParameter( "gpa" );
	String title = request.getParameter( "title" );
	String transcript = request.getParameter( "transcript" );

	//if degrees is equal to null this is really bad and should almost never happen
	DegreeContainer degrees = (DegreeContainer)session.getAttribute("DegreeContainer");
	//This flags that we were last at this page
	degrees.setIsMoreDegrees(true);

    degree d = degrees.getLastDegree();
    d.setAttribute("major", major);
	d.setAttribute("month", month);
	d.setAttribute("year", year);
	d.setAttribute("gpa", gpa);
	d.setAttribute("title", title);
	d.setAttribute("transcript", transcript);
    
    //add container back into session object
    session.setAttribute("DegreeContainer", degrees);
%>

<body>
<%
	
	student stu = (student)session.getAttribute("student");
	String firstName = (String)stu.getAttribute("firstName");
    String lastName = (String)stu.getAttribute("lastName");
	String middleName = (String)stu.getAttribute( "middleName" );
	String citizenship = (String)stu.getAttribute( "citizenship" );
	String residence = (String) stu.getAttribute( "residence" );
	String street = (String)stu.getAttribute( "street" );
	String city = (String)stu.getAttribute( "city" );
	String phone = (String)stu.getAttribute( "phone" );
	
	out.println(firstName + " " + middleName + " " + lastName +"</br>");
	out.println("Country of Citizenship: " + citizenship + "</br>");
	out.println("Country of Residence: " + residence + "</br>");
	out.println("Address </br>");
	out.println("Street: " + street + "</br>");
	out.println("City: " + city + "</br>");
	
	
	String resident = (String)stu.getAttribute( "resident" );
	if(resident != null){
		stu.setAttribute("resident",resident);
		String phoneCode = (String)stu.getAttribute( "phoneCode" );
		out.println("Resident: " + resident + "</br>");
		out.println("Phone Code: " + phoneCode + "</br>");
	}
	else if(request.getParameter( "moreDegrees" ) == null){
		String state = request.getParameter( "state" );
		String zipCode = request.getParameter( "zipCode" );
		out.println("State: " + state + "</br>");
		out.println("Zip Code: " + zipCode + "</br>");
	}
	out.println("Phone: " + phone  + "</br>");
	session.setAttribute("student", stu);

	
%>	


	<h1>More Degrees</h1>
	
	<form method="GET" action="location.jsp">
		<input type="hidden" name="moreDegrees" value="true"/>
	   <input type="submit" value="Submit Next Degree"/>
   </form>
   
   <form method="GET" action="specialization.jsp">
	   <input type="submit" value="Done"/>
   </form>

</body>
</html>